﻿function PopupNotifier($mouseOverObject, timeout, receiver) {
	var deactivationTimerID = null;

	function updateDeactivationTimer(receiver, timeout) {
		var wasActive = deactivationTimerID != null;

		if (wasActive)
			window.clearTimeout(deactivationTimerID);
		deactivationTimerID = window.setTimeout(function () { receiver(false); deactivationTimerID = null; }, timeout);
		return !wasActive;
	};

	$mouseOverObject.mousemove(function () {
		if (updateDeactivationTimer(receiver, timeout))
			receiver(true);
	});
}
